Skip to content

Fix ImpactX Plasma Lens - #222

Open
ax3l wants to merge 1 commit into
abel-framework:mainfrom
ax3l:fix-impactx-plasma-lens
Open

ax3l wants to merge 1 commit into
abel-framework:mainfrom
ax3l:fix-impactx-plasma-lens

Conversation

@ax3l

@ax3l ax3l commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Fix the ImpactX PlasmaLens usage:
Probably just used in separate branches, the class was never exported and had accumulated enough breakage that it could not have run against a modern ImpactX:

  • TaperedPL(units=0) - the keyword is unit, renamed upstream long ago; the call raised TypeError.
  • beam2particle_container(beam0, sim) passed the simulation object positionally into the nom_energy slot.
  • The simulation was built by hand without particle_shape or init_grids(), so it raised RuntimeError before tracking.
  • The integrated focusing strength was missing its length factor: TaperedPL(unit=0) takes k = L * g / (B*rho), but the code summed to g * c / E, i.e. a factor length too small.
  • The sign hard-coded electrons instead of using beam.charge_sign().
  • A BeamMonitor was constructed and never used.

track() now builds a lattice and delegates to run_impactx(), the same way InterstagePlasmaLensImpactX does, which removes the hand- rolled simulation setup entirely. num_slices and use_apertures are exposed; apertures are off by default to match the other PlasmaLens implementations.

Verified against PlasmaLensNonlinearThick, which models the same drift-kick sequence: beam sizes agree to <1e-4 relative and the offset-induced deflection to <5e-4, across plain / offset / tapered configurations.

The class was never exported from `abel/__init__.py` and never
referenced, and had accumulated enough breakage that it could not have
run against a modern ImpactX:

* `TaperedPL(units=0)` - the keyword is `unit`, renamed upstream long
  ago; the call raised `TypeError`.
* `beam2particle_container(beam0, sim)` passed the simulation object
  positionally into the `nom_energy` slot.
* The simulation was built by hand without `particle_shape` or
  `init_grids()`, so it raised `RuntimeError` before tracking.
* The integrated focusing strength was missing its length factor:
  `TaperedPL(unit=0)` takes `k = L * g / (B*rho)`, but the code summed
  to `g * c / E`, i.e. a factor `length` too small.
* The sign hard-coded electrons instead of using `beam.charge_sign()`.
* A `BeamMonitor` was constructed and never used.

`track()` now builds a lattice and delegates to `run_impactx()`, the
same way `InterstagePlasmaLensImpactX` does, which removes the hand-
rolled simulation setup entirely. `num_slices` and `use_apertures` are
exposed; apertures are off by default to match the other `PlasmaLens`
implementations.

Verified against `PlasmaLensNonlinearThick`, which models the same
drift-kick sequence: beam sizes agree to <1e-4 relative and the
offset-induced deflection to <5e-4, across plain / offset / tapered
configurations.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BGAJYtvSuTMamdj5oaTRHz
@ax3l ax3l added the bug Something isn't working label Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant